package ca.etsmtl.log430.lab3;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Observable;

/**
 * Component for modif 2 Display the mandatory course a student has not yet
 * completed.
 * 
 * @author Alexandre Parent
 * 
 */
public class MandatoryCourseNotDone extends Communication {

	public MandatoryCourseNotDone(Integer registrationNumber,
			String componentName) {
		super(registrationNumber, componentName);
	}

	public void update(Observable thing, Object notificationNumber) {

		if (registrationNumber.compareTo((Integer) notificationNumber) == 0) {

			Displays display = new Displays();
			Menus menu = new Menus();

			addToReceiverList("ListStudentsComponent");
			signalReceivers("ListStudentsComponent");
			
			Student student = menu
					.pickStudent(CommonData.theListOfStudents.listOfStudents);

			CourseList courseTaken = student.getCoursesTakenList();

			Collection<Course> mandatoryCourseList = new ArrayList<Course>();

			Course coursLOG120 = new Course("LOG120");
			Course coursLOG220 = new Course("LOG220");
			Course coursMAT210 = new Course("MAT210");
			Course coursLOG310 = new Course("LOG310");
			Course coursLOG430 = new Course("LOG430");

			if (!courseTaken.findCourse(coursLOG120))
				mandatoryCourseList.add(coursLOG120);
			if (!courseTaken.findCourse(coursLOG220))
				mandatoryCourseList.add(coursLOG220);
			if (!courseTaken.findCourse(coursMAT210))
				mandatoryCourseList.add(coursMAT210);
			if (!courseTaken.findCourse(coursLOG310))
				mandatoryCourseList.add(coursLOG310);
			if (!courseTaken.findCourse(coursLOG430))
				mandatoryCourseList.add(coursLOG430);

			String coursRestant = "";
			for (Course course : mandatoryCourseList) {
				coursRestant += course.getCourseID() + " ";
			}

			System.out.println("Cours restant : " + coursRestant);

		}
	}
}
